<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% alert ||= Alert.new; alert_counter ||= -1 %>
<% if alert_counter > 0 %>
  <div class="alert_separator"></div>
<% end %>
<% alert_counter = '{{id}}' if alert_counter == -1 %>
<%= form_for [@context, alert], :html => { :class => "alert displaying #{'blank' if alert.new_record?}" } do |f| %>
  <div class="links">
    <a href="#" class="displaying edit_link no-hover" title="{{#t}}Edit alert{{/t}}"><i class="icon-edit"></i></a>
    <a href="#" class="delete_link no-hover" title="{{#t}}Delete this alert{{/t}}"><i class="icon-trash"></i></a>
  </div>

  <div class="labelled_region">
    <span class="alert-label"><%= before_label :criteria, "Trigger an alert when" %></span>
    <ul class="criteria"></ul>
    <div class="add_criteria_line editing">
      <select title="<%= t :criteria, "Trigger an alert when" %>"></select>
      <a href="#" class="add_criterion_link icon-add" title="{{#t}}Add Trigger') %>" aria-label="<%= t('Add Trigger{{/t}}"><%= t 'buttons.add_criterion', "Trigger" %></a>
    </div>
  </div>

  <div class="labelled_region">
	  <span class="alert-label"><%= before_label :recipients, "Send a notification to" %></span>
	  <ul class="recipients"></ul>
	  <div class="add_recipients_line editing">
	    <select title="<%= t :recipients, "Send a notification to" %>"></select>
      <a href="#" class="add_recipient_link icon-add" title="{{#t}}Add Recipient') %>" aria-label="<%= t('Add Recipient{{/t}}"><%= t 'buttons.add_recipient', "Recipient" %></a>
	  </div>
  </div>

  <div class="labelled_region">
    <span class="alert-label"><%= before_label :repetition, "Repetition" %></span>
    <div class="repetition_group">
      <input type="radio" class="editing" name="repetition" value="none" checked="checked" id="repetition_none_<%= alert_counter %>" /> <label for="repetition_none_<%= alert_counter %>" class="no_repetition">{{#t}}Do not re-send alert{{/t}}</label><br class="editing"/>
      <input type="radio" class="editing" name="repetition" value="value" id="repetition_repetition_<%= alert_counter %>" /> <label for="repetition_repetition_<%= alert_counter %>" class="repetition" style="display:none;"><%= t('repetition_description', "Re-send alert every %{count} days until resolved", :count => "<span class='displaying'></span><input type='text' name='alert[repetition]' class='editing' size='2' />".html_safe) %></label>
    </div>
  </div>

  <div class="form-actions">
    <button class="editing Button cancel_button">{{#t}}Cancel{{/t}}</button>
    <button type="submit" class="editing Button Button--primary submit_button">{{#t}}Save Alert{{/t}}</button>
  </div>
<% end %>
